package cn.brilliantfuture.commentry.safe.impl;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import cn.brilliantfuture.commentry.safe.VerifyMessageLocal;

/**
 * 
 * Title: Communication Entry
 * 
 * Author:  LiTian  
 *
 * Date: 2012-3-29
 * 
 * Description:
 * 
 */
@Stateless
public class VerifyMessageImpl implements VerifyMessageLocal {
	
	@PersistenceContext(unitName = "commentry-jpa")
	EntityManager entityManager;

	@SuppressWarnings("unchecked")
	public Integer validAppParam(String appKey, String appCode) {
		List<Integer> list = entityManager.createNativeQuery("select group_id from user_group where group_sn = '" + appKey + "' and app_code = '" + appCode + "'").getResultList();
		
		if (null != list)
			if (list.size() > 0)
				return list.get(0);
			else
				return null;
		else
			return null;
	}

}
